package com.tags.controller;

import com.common.domain.vo.TagsListVO;
import com.common.result.Result;
import com.tags.service.TagsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author 路亚
 * @version 0.1
 * @className TagsController
 * @description
 * @date 2024/12/10 20:40
 * @since jdk11
 */
@RestController
@RequestMapping("/tags")
@RequiredArgsConstructor
@Slf4j
public class TagsController {

    private final TagsService tagsService;

    // 2.1.2.1.新增短剧分类
    @PostMapping("/add")
    public Result add(@RequestBody Map<String, String> map){
        log.info("add tags:{}", map);
        tagsService.saveTags(map);
        return Result.success();
    }

    // 2.1.2.2.删除短剧分类
    @DeleteMapping("/delete")
    public Result delete(String tags){
        log.info("delete tags:{}", tags);
        tagsService.removeTags(tags);
        return Result.success();
    }

    // 2.1.2.3.查询短剧分类
    @GetMapping("/list")
    public Result list(){
        List<TagsListVO> tagsList = tagsService.listTags();
        return Result.success(tagsList);
    }
}
